package weatherapp.ui;

import weatherapp.parser.WeatherData;
import weatherapp.util.ImageUtil;

import javax.swing.*;
import java.awt.*;

public class SimpleWeatherDisplay extends WeatherDisplay {
    public SimpleWeatherDisplay(WeatherData data) {
        super(data);
        JFrame frame = new JFrame("天气信息");
        JLabel tempLabel = new JLabel("温度: " + data.getTemperature() + " °C");
        JLabel humidityLabel = new JLabel("湿度: " + data.getHumidity() + "%");
        JLabel iconLabel = new JLabel(new ImageIcon(ImageUtil.loadImage(data.getIconUrl())));
        frame.setLayout(new GridLayout(3, 1));
        frame.add(tempLabel);
        frame.add(humidityLabel);
        frame.add(iconLabel);
        frame.setSize(300, 200);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}
